home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 January / macformat-020.iso / Shareware City / Applications / Alpha.5.96 folder / Tcl / UserCode / MacPerl.tcl.old < prev    next >
Encoding:
Text File  |  1994-08-07  |  20.9 KB  |  662 lines  |  [TEXT/ALFA]

  1. #############################################################################
  2. # MacPerl.tcl
  3. #
  4. # This is a set of routines that allow Alpha to act as a front end for the
  5. # standalone MacPerl application and that allow Perl scripts to be used as 
  6. # text filters in Alpha.
  7. #
  8. #############################################################################
  9. # Features:
  10. #
  11. # A Perl menu is created that allows the following actions:
  12. #
  13. # 1.  Selected text (or the entire buffer) may be interpreted as a Perl 
  14. #     script by MacPerl.
  15. #    
  16. # 2.  A selected Perl script file may be executed by MacPerl.
  17. #
  18. # 3.  Perl scripts that read from standard input and write to standard
  19. #     output may be used as text filters within Alpha.  
  20. #
  21. #     A submenu of "preattached" Perl scripts is constructed from the 
  22. #     contents of a "Text Filters" folder within the main MacPerl folder.
  23. #     This folder will be created if it doesn't already exist.
  24. #
  25. #     Besides the "preattached" filters, a disk file or an Alpha buffer
  26. #     which contains a Perl script may be chosen as the text filter.
  27. #     (The latter option allows simple one-time scripts to be created and 
  28. #     applied on the fly.  This can be very useful because, even
  29. #     with the overhead to start up MacPerl, large-scale global search-
  30. #     and-replace operations (hundreds of replaces) are substantially faster
  31. #     in MacPerl than in Alpha.)
  32. #
  33. #     The output of Perl text filters may be chosen to overwrite the 
  34. #     selected Alpha text or else written into a new window.  (Everything 
  35. #     is undoable, in any case).
  36. #
  37. #     The filter may be applied either to the currently selected text
  38. #     or to the entire buffer.
  39. #
  40. # 4.  The temporary i/o files used by the text filter mechanism may be 
  41. #     examined.
  42. #
  43. # 5.  The Perl menu may be rebuilt, in case files are added or removed 
  44. #     from the "Text Filters" folder.
  45. # A sampling of useful :-) Perl scripts are included in the folder "Text 
  46. # Filters", in the :Tcl:UserCode folder.
  47. # You should drag this folder into your MacPerl folder, where MacPerl.tcl 
  48. # will look for it.  The "Text Munging" scripts are largely from the 
  49. # Nutshell book ("Programming Perl") and the s2p script is my adaptation 
  50. # of the standard script that converts Unix "sed" scripts to Perl (adapted 
  51. # to work without using the C preprocessor).  The others may be useful 
  52. # examples as well.
  53. #############################################################################
  54. #
  55. # If you don't already have MacPerl, it's available by anonymous ftp from
  56. # the umich site
  57. #
  58. #   mac.archive.umich.edu    [141.211.165.34]    mac/development/languages                            (4)
  59. #
  60. # and its mirrors.  Also, MacPerl's home site is 
  61. #
  62. #   ftp.switch.ch            [130.59.1.40]        software/mac/src/mpw_c
  63. #
  64. # MacPerl was written (ported to the Mac) by 
  65. #        Matthias Neeracher <neeri@iis.ee.ethz.ch> , and
  66. #        Tim Endres <time@ice.com>.
  67. #
  68. #############################################################################
  69. # Authors: W. Thomas Pollard (pollard@chem.columbia.edu)
  70. #          Martijn Koster (m.koster@nexor.co.uk)
  71. #
  72. # Version History:
  73. #
  74. # 1.1  8/94  -  'quitMacperl' added.
  75. #               perl-mode file-marking updated for Alpha 5.90
  76. #               Simplified installation via 'loadMacperl'(Pete Keleher). 
  77. # 1.0  7/94  -  perl-mode setup updated for Alpha 5.85:
  78. #                    keyword colorization supported
  79. #                    custom file-marking added
  80. #               #! lines in filter scripts now handled correctly 
  81. #               Workarounds installed for AppleEvent bug in MacPerl 4.1.3
  82. # 0.9  3/94  -  perl-mode stuff added, and
  83. #               highlighted 'Perl commands' file (man page) prepared
  84. #               minor bug fixes, too
  85. # 0.8  3/94  -  flags are now check-marked
  86. # 0.7  3/94  -  nested Text Filters folder now supported
  87. #               menu format modified somewhat
  88. # 0.6  3/94  -  'applyToBuffer' flag added
  89. #               scripts in Alpha buffers can now be used as filters 
  90. # 0.5  2/94  -  'filters', 'open special' submenu added
  91. #               'overwrite' flag added
  92. # 0.2  1/94  -  menu support added (MK)
  93. #               'execute selection', 'execute buffer' commands added
  94. # 0.1  9/93  -  text filter functionality created (WTP)
  95. #                  
  96. #   Comments, suggestions, bug reports, etc., should be directed to 
  97. #   Tom Pollard (pollard@chem.columbia.edu).
  98. #
  99. #############################################################################
  100. #  Default settings for the Perl mode flags  
  101. #
  102. set perlOverwrite 1
  103. set perlUsebuffer 1
  104.  
  105. #############################################################################
  106. #  To install the MacPerl package, the user is prompted to locate his
  107. #  MacPerl application.  This information (necessary for building the MacPerl
  108. #  menu) recorded in UserStartup.tcl, along with commands that will load
  109. #  MacPerl mode automatically in the future.
  110. #
  111. proc loadMacPerl {} {
  112.     global macperlPath mode
  113.     if {[askyesno "Install MacPerl mode?"] == "yes"} {
  114.         set f [getfile {Where is your MacPerl application?"}]
  115.         
  116.         # modify UserStartup.tcl so that Perl mode loads automatically
  117.         addUserLine "\r\# The next several lines enable MacPerl mode."
  118.         addUserLine "set macperlPath \"$f\""
  119.         addUserLine "enableMenuItem install macPerl 0"
  120.         addUserLine "lappend modes Perl"
  121.         addUserLine "set dummyProc(Perl) dummyPerl"
  122.         addUserLine "set modeMenus(Perl) { perlMenu }"
  123.         addUserLine "lappend modeSuffixes {*.pl} { set winMode Perl }"
  124.         addUserLine "newModeVar Perl elecRBrace {0} 1"
  125.         addUserLine "newModeVar Perl electricSemi {0} 1"
  126.         addUserLine "newModeVar Perl wordBreak {(\$)?[a-zA-Z0-9_]+} 0"
  127.         addUserLine "newModeVar Perl prefixString {# } 0"
  128.         addUserLine "newModeVar Perl elecLBrace {0} 1"
  129.         addUserLine "newModeVar Perl wordWrap {0} 1"
  130.         addUserLine "newModeVar Perl funcExpr {^sub *([+-a-zA-Z0-9]+)} 0"
  131.         addUserLine "newModeVar Perl wordBreakPreface {[^a-zA-Z0-9_\$]} 0"
  132.         addUserLine "newModeVar Perl optionIsMeta {1} 1\r\r"
  133.         
  134.         # enable Perl mode for this session
  135.         set macperlPath $f
  136.         rebuildPerlMenu
  137.         buildModeFlagMenu
  138.         enableMenuItem install macPerl 0
  139.  
  140.         # reset the mode, so that Perl menu is inserted if required
  141.         set currentMode $mode
  142.         changeMode none
  143.         changeMode $currentMode
  144.     }
  145. }
  146.  
  147. #############################################################################
  148. #  Return paths to standard files, based on the path to MacPerl:
  149. #
  150. proc macperlFolder {} {
  151.    global macperlPath
  152.    regexp {(.*):([^:]*)} $macperlPath pathname dirname filename
  153.    return ${dirname}:
  154. }
  155.  
  156. proc stdinPath {} {
  157.    return [macperlFolder]STDIN
  158. }
  159.  
  160. proc stdoutPath {} {
  161.    return [macperlFolder]STDOUT
  162. }
  163.  
  164. proc scriptPath {} {
  165.    return [macperlFolder]SCRIPT
  166. }
  167.  
  168. proc scriptFolder {} {
  169.    return "[macperlFolder]Text Filters:"
  170. }
  171.  
  172. #############################################################################
  173. #  Toggle the "overwrite" flag.  If true, then the output of a Perl filter
  174. #  is inserted in place of the originally selected text.  Otherwise, it is
  175. #  placed in a new window.  The names of the routines reflect the condition
  176. #  of the flag _before_ the routine is called, so that the menu makes more
  177. #  sense.
  178. proc overwriteSelection {} {
  179.     global perlMenu perlOverwrite
  180.     if {$perlOverwrite} then {
  181.         set perlOverwrite 0
  182.     } else {
  183.         set perlOverwrite 1
  184.     }
  185.     markMenuItem $perlMenu overwriteSelection $perlOverwrite
  186. }
  187.  
  188. #############################################################################
  189. #  Toggle the "usebuffer" flag.  If true, then the Perl filter is applied to 
  190. #  the entire buffer.  Otherwise, only the selected text is filtered.
  191. proc applyToBuffer {} {
  192.     global perlMenu perlUsebuffer
  193.     if {$perlUsebuffer} then {
  194.            set perlUsebuffer 0
  195.     } else {
  196.            set perlUsebuffer 1
  197.     }
  198.     markMenuItem $perlMenu applyToBuffer $perlUsebuffer
  199. }
  200.  
  201. #############################################################################
  202. #  This is a generally useful proc that builds a hierarchical menu 
  203. #  from the files in a given folder and all subfolders.  As the menu is
  204. #  built, the pathnames of the various files are saved in the array
  205. #  indicated  by $filePaths.  The index of the file's path in this array
  206. #  is formed by concatenating the submenu name and filename, allowing the
  207. #  pathname to be retrieved by the procedure $proc when the menu item is
  208. #  selected.
  209. #
  210. proc buildSubMenu {folder name proc filePaths} {
  211.     global $filePaths
  212.     if {$name == 0} {
  213.         set name [file tail [file dirname $folder]]
  214.     }
  215.     if {$proc == 0} {
  216.         set pproc ""
  217.     } else {
  218.         set pproc "-p $proc"
  219.     }
  220.     set menu {}
  221.     set filenames [glob -nocomplain  $folder\*]
  222.     if {[llength $filenames] > 0} {
  223.        foreach m $filenames {
  224.           if {[file isdirectory $m]} {
  225.               lappend menu [buildSubMenu ${m}: 0 $proc $filePaths] 
  226.           } elseif {[file isfile $m]} {
  227.               set fname [file tail $m]
  228.               lappend menu $fname
  229.               set ${filePaths}($name:$fname) $m
  230.           }
  231.          }
  232.     }
  233.     return [concat {menu -m -n} [list $name] $pproc [list $menu]]
  234. }
  235.  
  236. #############################################################################
  237. #  Build a submenu of "preattached" Perl filters using the names of the 
  238. #  scripts in the Text Filters directory
  239. #
  240. proc perlFilterMenu {} {
  241.     global perlFilterPath HOME
  242.     set scriptDir [scriptFolder]
  243.     if {![file exists $scriptDir]} {
  244.        message "Copying \":Tcl:UserCode:Text Filters\" to MacPerl folder." 
  245.        cphier "$HOME:Tcl:UserCode:Text Filters" [macperlFolder]
  246.        message ""
  247.     }
  248.     return [buildSubMenu $scriptDir TextFilters perlExecuteFilter perlFilterPath]
  249. }
  250.  
  251. proc rebuildPerlMenu {} {
  252.     global perlMenu perlOverwrite perlUsebuffer
  253.             
  254.     set perlMenu "•132"
  255.     menu -n $perlMenu [ concat {
  256.         "macperl/-"
  257.         "(-"
  258.         "runTheSelection"
  259.         "runTheBuffer"
  260.         "runAFile"
  261.         "(-"
  262.         } [list [perlFilterMenu]] {
  263.         {menu -n OtherTextFilters {
  264.            "selectABuffer"
  265.            "selectAFile"
  266.            }
  267.         } 
  268.         "applyToBuffer"
  269.         "overwriteSelection"
  270.         "(-"
  271.         {menu -m -n openSpecial -p perlOpenFile {
  272.            "STDIN"
  273.            "STDOUT"
  274.            "SCRIPT"
  275.            }
  276.         } 
  277.         "(-"
  278.         "rebuildPerlMenu"
  279.         "quitMacperl"
  280.         } ]
  281.     perlMenuSetFlags
  282. }
  283.  
  284. proc perlMenuSetFlags {} {
  285.     global perlMenu perlOverwrite perlUsebuffer
  286.     markMenuItem $perlMenu overwriteSelection $perlOverwrite
  287.     markMenuItem $perlMenu applyToBuffer $perlUsebuffer
  288. }
  289.  
  290. if ([info exists macperlPath]) {
  291.     rebuildPerlMenu
  292. }
  293.  
  294. #############################################################################
  295. # Switch to MacPerl:
  296. proc macperl {} {
  297.     global macperlPath
  298.     set name [checkRunning MacPerl McPL macperlPath]
  299.     if {[string length $name]} {
  300.         switchTo "MacPerl"
  301.     } else {
  302.         alertnote "Couldn't run MacPerl"
  303.     }
  304. }
  305.  
  306. #############################################################################
  307. # Quit a running MacPerl app:
  308. proc quitMacperl {} {
  309.     foreach proc [processes] {
  310.         set sig [lindex $proc 1]
  311.         if {$sig == "McPL"} {
  312.             sendQuitEvent [lindex $proc 0]
  313.             # switchTo is necessary to keep MacPerl from blinking
  314.             switchTo [lindex $proc 0]    
  315.         }
  316.     }
  317. }
  318.  
  319. proc sendQuitEvent {appname} {
  320.     AEBuild $appname aevt quit 
  321. }
  322.  
  323. #############################################################################
  324. #
  325. proc perlOpenFile {menu name} {
  326.     set filename [macperlFolder]$name
  327.     if {[file exists $filename]} {
  328.         edit $filename
  329.     } else {
  330.         alertnote "That file doesn't exist yet"
  331.     }
  332. }
  333.  
  334. #############################################################################
  335. # Get a script file to run under MacPerl:
  336. #
  337. proc runAFile {} {
  338.     if {! [catch {getfile "Select a Perl script"} path]} {
  339.             perlExecuteFile $path
  340.     }
  341. }
  342.  
  343. #############################################################################
  344. # Tell MacPerl to run a script file:
  345. #
  346. proc perlExecuteFile {path} {
  347.     global macperlPath
  348.     if {[string length $path]} {
  349.         set name [checkRunning MacPerl McPL macperlPath]
  350.         if {[string length $name]} {
  351.             dosc -c 'McPL' -r -f $path
  352.             switchTo "MacPerl"
  353.         } else {
  354.             alertnote "Couldn't run MacPerl"
  355.         }
  356.     } else {
  357.             alertnote "No file specified to execute"
  358.     }
  359. }
  360.  
  361. #############################################################################
  362. # Run the buffer as a MacPerl script:
  363. #
  364. proc runTheBuffer {} {
  365.     perlExecuteScript [getText 0 [maxPos]]
  366. }
  367.  
  368. #############################################################################
  369. # Run the selection as a MacPerl script:
  370. # (No special arrangements are made to provide input or capture the output)
  371. proc runTheSelection {} {
  372.     perlExecuteScript [getSelect]
  373. }
  374.  
  375. #############################################################################
  376. # Run a MacPerl script, passed explicitly as a string:
  377. # (No special arrangements are made to provide input or capture the output)
  378. proc perlExecuteScript {script} {
  379.     global macperlPath
  380.     if {$script != ""} {
  381. # MacPerl 4.1.3 bug 
  382.         writeScript $script
  383.         set name [checkRunning MacPerl McPL macperlPath]
  384.         if {[string length $name]} {
  385. # MacPerl 4.1.3 bug
  386. #             dosc -c 'McPL' -r -s $script         
  387. # MacPerl 4.1.3 bug 
  388.             dosc -c 'McPL' -r -f [scriptPath]    
  389.             switchTo "MacPerl"
  390.        } else {
  391.             alertnote "Couldn't run MacPerl"
  392.        }
  393.     } else {
  394.         alertnote "Empty script"
  395.     }
  396. }
  397.  
  398. #############################################################################
  399. # Run a Perl script filter selected from the menu:
  400. #
  401. proc perlExecuteFilter {menu name} {
  402.     global perlFilterPath
  403.     set path $perlFilterPath($menu:$name)
  404.     set coreScript [readFile $path]
  405.     if {$coreScript != -1} {
  406.         set script [wrapFilterScript $coreScript]
  407.         filterThruMacperl $script
  408.     } else {
  409.         alertnote "Couldn't read the script file : $path"
  410.         return
  411.     }
  412. }
  413.  
  414. #############################################################################
  415. # Ask for a file containing a Perl script to use as a filter:
  416. #
  417. proc selectAFile {} {
  418.     if {! [catch {getfile "Select a MacPerl script"} path]} {
  419.         set coreScript [readFile $path]
  420.         if {$coreScript != -1} {
  421.             set script [wrapFilterScript $coreScript]
  422.             filterThruMacperl $script
  423.         } else {
  424.             alertnote "Couldn't read the script file : $path"
  425.             return
  426.         }
  427.     }
  428. }
  429.  
  430. #############################################################################
  431. # Ask for an Alpha buffer containing a Perl script to use as a filter:
  432. #
  433. proc selectABuffer {} {
  434.     set windows [winNames]
  435.     if {[llength $windows] > 1} {
  436.         set current [lindex $windows 0]
  437.         set name [listpick [lsort $windows]]
  438.         if {[string length $name]} {
  439.             bringToFront $name
  440.             set coreScript [getText 0 [maxPos]]
  441.             if {[string length $coreScript]} {
  442.                 set script [wrapFilterScript $coreScript]
  443.                 bringToFront $current
  444.                 filterThruMacperl $script
  445.             } else {
  446.                 bringToFront $current
  447.             }
  448.            }
  449.     }
  450. }
  451.  
  452. #############################################################################
  453. # Filter selection through a Perl script:
  454. proc filterThruMacperl {script} {
  455.     global macperlPath perlOverwrite perlUsebuffer
  456.  
  457.     set name [checkRunning MacPerl McPL macperlPath]
  458.     if {[string length $name]} {
  459.         writeStdin
  460.         writeStdout
  461. # MacPerl 4.1.3 bug
  462. #        dosc -c 'McPL' -t 0 -s $script             
  463. # MacPerl 4.1.3 bug 
  464.         dosc -c 'McPL' -t 0 -f [scriptPath]        
  465.     } else {
  466.         alertnote "Couldn't run MacPerl"
  467.     }
  468.     
  469.     if {!$perlOverwrite} new
  470.     if {$perlUsebuffer} {
  471.         pasteStdout 0 [maxPos]
  472.     } else {
  473.         pasteStdout [getPos] [selEnd]
  474.     }
  475. }
  476.  
  477. #############################################################################
  478. #  Take a Perl script and add commands to take the file STDIN as standard
  479. #  input and STDOUT as standard output.  This allows scripts written as
  480. #  Unix command-line filters to be used in the (non-MPW) Mac environment as
  481. #  text filters.
  482. #
  483. #  If there's already a #! line in the script, then the new commands
  484. #  are added after that line.  If there was no #! line in the first place,
  485. #  one is added, in case MacPerl is set up to require it (can't hurt...) 
  486. #
  487. proc wrapFilterScript {coreScript} {
  488.  
  489.     if {[regexp -indices {(#![     !-~]*)} $coreScript allofit cmdln]} {
  490.         set endPos [lindex $cmdln 1]
  491.         set filterHead [string range $coreScript 0 [expr $endPos+1]]
  492.         set coreScript [string range $coreScript [expr $endPos+2] end]
  493.     } else {
  494.         set filterHead "#!/bin/perl\n"
  495.     }
  496.     append filterHead "\$macperlDir = \"[macperlFolder]\" ;\n"
  497.     append filterHead "open(STDIN, \"<[stdinPath]\" ) ;\n"
  498.     append filterHead "open(STDOUT, \">[stdoutPath]\" ) ;\n"
  499.     append filterHead "@ARGV = (\"[stdinPath]\") ;\n"
  500.     append filterHead "select(STDOUT) ;\n\n"
  501.     
  502.     set filterTail "close STDIN ;\nclose STDOUT ;\n"
  503.         
  504.     set script $filterHead
  505.     append script $coreScript
  506.     append script $filterTail
  507.     
  508.     writeScript $script
  509.     return $script
  510. }        
  511.  
  512. #############################################################################
  513. #  Paste the text of the file STDOUT in place of the current selection.
  514. #
  515. proc pasteStdout {from to} {
  516.     set result [readFile [stdoutPath]]
  517.     if {$result != -1} {
  518.         deleteText $from $to
  519.         insertText $result
  520.         catch shrinkWindow
  521.         goto 0
  522.     } else {
  523.         alertnote "Couldn't find the output file : STDOUT"
  524.     }
  525. }    
  526. #        replaceText [getPos] [selEnd] $result
  527.  
  528. #############################################################################
  529. #  Extend the current selection to encompass complete lines.  If the 
  530. #  'applyToBuffer' flag is checked, then the entire buffer is selected.
  531. #
  532. proc completeSelection {} {
  533.     global perlUsebuffer
  534.     if {$perlUsebuffer} {
  535.         set start 0
  536.         set end [maxPos]
  537.     } else {
  538.         set start [lineStart [getPos]]
  539.         set end [nextLineStart [expr [selEnd]-1]]
  540.     }
  541.     if {$end == $start} {set end [nextLineStart [selEnd]]}
  542.     select $start $end
  543. }
  544.  
  545. #############################################################################
  546. #  writeStdin: Extend the selection, as appropriate, and write it to the 
  547. #     STDIN file in the MacPerl directory.
  548. #  writeStdout: Write the extended selection to the STDOUT file.  This will
  549. #      then be the default output in case MacPerl hangs. 
  550. #  writeScript: Write the SCRIPT file in the MacPerl directory.  This is
  551. #     only useful for debugging - it's not used by the rest of the code. 
  552. #
  553. proc writeStdin {} {
  554.     completeSelection
  555.     set tmpfid [open [stdinPath] "w+"]
  556.     puts $tmpfid [getSelect] 
  557.     close $tmpfid
  558. }
  559.  
  560. proc writeStdout {} {
  561.     completeSelection
  562.     set tmpfid [open [stdoutPath] "w+"]
  563.     puts $tmpfid [getSelect] 
  564.     close $tmpfid
  565. }
  566.  
  567. proc writeScript {script} {
  568.     set tmpfid [open [scriptPath] "w+"]
  569.     puts $tmpfid $script 
  570.     close $tmpfid
  571. }
  572.  
  573. #############################################################################
  574. #  Read and return the complete contents of the specified file.
  575. #
  576. proc readFile {fileName} {
  577.     if {[file exists $fileName] && [file readable $fileName]} {
  578.        set fileid [open $fileName "r"]
  579.        set contents ""
  580.        while {[gets $fileid nextLine] != -1} {
  581.           append contents $nextLine "\n"
  582.        }
  583.        close $fileid
  584.        return $contents
  585.     } else {
  586.        return -1
  587.     }
  588. }
  589.  
  590. ##############################################################################
  591. # Automatic subroutine marking for Perl mode in Alpha 5.85
  592. #
  593. # (code stolen shamelessly from 'tclMarkFile' in 'tcl.tcl')
  594. #
  595.  
  596. proc PerlMarkFile {} {
  597.     set end [maxPos]
  598.     set pos 0
  599.     set l {}
  600.     while {![catch {search -f 1 -r 1 -m 0 -i 0 {^sub} $pos} res]} {
  601.         set start [lindex $res 0]
  602.         set end [nextLineStart $start]
  603.         set text [lindex [getText $start $end] 1]
  604.         set pos $end
  605.         set inds($text) [lineStart [expr $start - 1]]
  606.     }
  607.  
  608.     if {[info exists inds]} {
  609.         foreach f [lsort [array names inds]] {
  610.             set next [nextLineStart $inds($f)]
  611.             setNamedMark $f $inds($f) $next $next
  612.         }
  613.     }
  614. }
  615.  
  616. proc dummyPerl {} {
  617. }
  618.  
  619. ##############################################################################
  620. # Perl mode definitions  (for Alpha 5.85+)
  621. #
  622.  
  623. set perlKeywords {
  624. accept alarm atan2 bind binmode caller chdir chmod chop chown chroot 
  625. close closedir connect continue cos crypt dbmclose dbmopen defined 
  626. delete die do dump each else elsif eof eval exec exit exp fcntl fileno 
  627. flock for foreach fork getc getlogin getpeername getpgrp getppid 
  628. getpriority getgrnam gethostbyname getnetbyname getprotobyname getpwuid 
  629. getgrgid getservbyname gethostbyaddr getnetbyaddr getprotobynumber 
  630. getservbyport getpwent getgrent gethostent getnetent getprotoent 
  631. getservent setpwent setgrent sethostent setnetent setprotoent setservent 
  632. endpwent endgrent endhostent endnetent endprotoent endservent 
  633. getsockname getsockopt gmtime goto grep hex if index int ioctl join keys 
  634. kill last length link listen local localtime log lstat lstat mkdir 
  635. msgctl msgget msgsnd msgrcv next oct open opendir ord pack pipe pop 
  636. print print printf printf push q qq qx rand read readdir readlink recv 
  637. redo rename require reset return reverse rewinddir rindex rindex rmdir 
  638. scalar seek seekdir select semctl semget semop send setpgrp setpriority 
  639. setsockopt shift shmctl shmget shmread shmwrite shutdown sin sleep 
  640. socket socketpair sort splice split sprintf sqrt srand stat study sub 
  641. substr symlink syscall sysread system syswrite tell telldir time times 
  642. tr truncate umask undef unless unlink unpack unshift until utime values 
  643. vec wait waitpid wantarray warn while write eq ne cmp lt gt le ge @_ $_ $.  
  644. $/ $, $" $\\ $\# $% $= $- $~ $^ $| $$ $? $& $` $' $+ $* $0 $1 $2 $3 $4 $5 
  645. $6 $7 $8 $9 $[ $] $; $! $@ $< $> $( $) $: $^D $^F $^I $^P $^T $^W $^X 
  646. $ARGV @ARGV @INC %INC $ENV $SIG
  647. }
  648. regModeKeywords -e {#} -c red -k blue Perl $perlKeywords
  649. unset perlKeywords
  650.  
  651. ##############################################################################
  652.